import re
import urllib.request as r
import urllib.error as e
def test(url,page):
    html=r.urlopen(url).read()
    result=re.compile(r'src="(.+?\.jpg)"').findall(html)
    result=result[0]
    x=1
    for imaget in result:
        try:
            r.urlretrieve(imaget, 'F:/美女/%s.jpg' % x)
        except e.URLError as p:
            if hasattr(p,'code'):
                x+=1
            if hasattr(p,'reason'):
                x+=1
for i in range(10):
    url='http://www.meituba.com/tag/tuinvlang/%s.html'%i
    test(url,i)





